from kivy.logger import Logger
from kivy.uix.image import Image



class PosterButton(Image):
	def __init__(self, screen_factory, show, **kwargs):
		super(PosterButton, self).__init__(
				source=show.detail_poster,
				size_hint=(None, None),
				allow_stretch = False,
				keep_ratio = True,
				**kwargs
			)
		self.show = show
		self.screen_factory = screen_factory

	def on_touch_up(self, touch):
		if self.collide_point(touch.pos[0], touch.pos[1]):
			Logger.info("Select %s", self.show.title)
			self.screen_factory.set_screen("Main")
			return True
		return super(PosterButton, self).on_touch_up(touch)


